<?php
if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

class Feedback1_layanan extends CI_Controller {

	function __construct() {
		parent::__construct();

		//jika digunakan di mayoritas function, panggil disini
		//model
		$this->load->model('m_feedback1_layanan');

		//library breadcrum/untuk navigasi
		$this->load->library(array('breadcrumb','form_validation'));
		$this->load->helper(array('slug','id_date'));
	}

	function index() {

		//rule type pada function ini: Read
		$this->rule->type('R');

		//Layout
		//title
		$this->layout->set_title('Verifikasi Feedback 1');

		//meta description jika perlu
		$this->layout->set_desc('Made with love by Raksa Abadi Informatika');

		//css tambahan bila perlu
		$this->layout->set_include('css', 'themes/back/css/datatables/dataTables.bootstrap.css');
		$this->layout->set_include('js', 'themes/back/bundle/datepicker/jquery-ui.js');
		$this->layout->set_include('js', 'themes/back/bundle/datepicker/datepicker-id.js');
		$this->layout->set_include('css', 'themes/back/bundle/datepicker/datepicker.css');

		//breadcrumb/untuk navigasi
		$this->breadcrumb->clear();
		$this->breadcrumb->add_crumb('Beranda', site_url());
		$this->breadcrumb->add_crumb('Verifikasi Feedback 1');	
		$this->breadcrumb->add_crumb('Layanan');			

		$tgl_awal		= $this->session->userdata('tgl_awal');
		$tgl_akhir	= $this->session->userdata('tgl_akhir');
		$ppk   			= $this->session->userdata('ppk');

		//paging dan ambil data dari model
		$this->load->library('paging');                         					//Load library "paging"
    $config['sql']      				= $this->m_feedback1_layanan->get(iddate2dbdate($tgl_awal),iddate2dbdate($tgl_akhir),$ppk);	//Query SQL - bukan array lho ya...
    $config['per_page'] 				= 15;                            			//jumlah item tiap halaman
    $data = $this->paging->create_pagination($config);   							//Load fungsi di library "paging" untuk membuat pagination. 

    //judul besar
		$data['primary_title'] 			= '<i class="ion-android-note"></i> Verifikasi Feedback 1';
		$data['sub_primary_title'] 	= '';
		$kd_ppk											= $this->session->userdata('ppk');
		$data['ppk']								= $this->m_feedback1_layanan->get_detail_ppk($kd_ppk);

		//menghilangka session jika ada
		$this->session->unset_userdata('keyword');

		//menggunakan theme back
		$this->layout->theme('back','feedback1_layanan/index', $data);
	}

	function cari() {

		//rule type pada function ini: Read
		$this->rule->type('R');

		//Layout
		//title
		$this->layout->set_title('Cari Data feedback1_layanan');

		//meta description jika perlu
		$this->layout->set_desc('Made with love by Raksa Abadi Informatika');

		//css tambahan bila perlu
		$this->layout->set_include('css', 'themes/back/css/datatables/dataTables.bootstrap.css');

		//js tambahan jika perlu
		$this->layout->set_include('js', 'themes/back/js/plugins/datatables/jquery.dataTables.js');
		$this->layout->set_include('js', 'themes/back/js/plugins/datatables/dataTables.bootstrap.js');

		//breadcrumb/untuk navigasi
		$this->breadcrumb->clear();
		$this->breadcrumb->add_crumb('Beranda', site_url());
		$this->breadcrumb->add_crumb('feedback1_layanan');	

		//buat cari
		if(isset($_POST['keyword'])){
			$data['keyword'] = $this->input->post('keyword');
			$this->session->set_userdata('keyword', $data['keyword']);
		} else {
			$data['keyword'] = $this->session->userdata('keyword');
		}	

		//paging dan ambil data dari model
		$this->load->library('paging');                         		//Load the "paging" library
    $config['sql']      				= $this->m_feedback1_layanan->get_cari($data['keyword']);//your SQL - bukan array lho ya...
    $config['per_page'] 				= 15;                            //Display items per page
    $data = $this->paging->create_pagination($config);   				//Load function in "paging" libraryfor create pagination. 

    //judul besar
		$data['primary_title'] 			= '<i class="ion-android-note"></i> Master';
		$data['sub_primary_title'] 	= 'Merupakan induk dari semua data';

		//menggunakan theme back
		$this->layout->theme('back','feedback1_layanan/index', $data);
	}

	function detail($kd_klaim = '') {

		//rule type pada function ini: Read
		$this->rule->type('R');

		//parameter yang dipelukan query
		$params = array($kd_klaim);

		//Layout
		//title
		$this->layout->set_title('Detail Klaim');

		//breadcrumb/untuk navigasi
		$this->breadcrumb->clear();
		$this->breadcrumb->add_crumb('Beranda', site_url());
		$this->breadcrumb->add_crumb('Verifikasi Feedback 1');
		$this->breadcrumb->add_crumb('Layanan', site_url('feedback1_layanan'));
		$this->breadcrumb->add_crumb('Detail Klaim');

		//judul besar
		$data['primary_title'] = '<i class="ion-android-note"></i> Verifikasi Feedback 1';
		$data['sub_primary_title'] = '';

		//ambil data dari model dengan berdasarkan parameter diatas
		$data['list'] 		= $this->m_feedback1_layanan->get_by($params);
		$data['diagnosa']	= $this->m_feedback1_layanan->get_diagnosa($params);

		//menggunakan theme back
		$this->layout->theme('back','feedback1_layanan/detail', $data);
	}

	function edit($kd_feedback1_layanan = '') {

		//rule type pada function ini: Update
		$this->rule->type('U');

		//parameter yang dipelukan query
		$params = array($kd_feedback1_layanan);

		//layout
		//title
		$this->layout->set_title('Edit Data feedback1_layanan');

		//js tambahan
		$this->layout->set_include('js', 'themes/general/bundle/jquery_validation/jquery.validate.min.js', 'header');
		$this->layout->set_include('js', 'themes/general/bundle/jquery_validation/localization/messages_id.min.js', 'header');
		$this->layout->set_include('js', 'themes/general/bundle/select2/select2.min.js', 'header');
		$this->layout->set_include('js', 'themes/back/bundle/datepicker/jquery-ui.js');
		$this->layout->set_include('js', 'themes/back/bundle/datepicker/datepicker-id.js');
		$this->layout->set_include('css', 'themes/back/bundle/datepicker/datepicker.css');
		$this->layout->set_include('js', 'themes/back/bundle/select2/select2.min.js');
		$this->layout->set_include('css', 'themes/back/bundle/select2/select2.min.css');

		//breadcrumb/untuk navigasi
		$this->breadcrumb->clear();
		$this->breadcrumb->add_crumb('Beranda', site_url());
		$this->breadcrumb->add_crumb('feedback1_layanan', site_url('feedback1_layanan'));
		$this->breadcrumb->add_crumb('Edit feedback1_layanan');

		//judul besar
		$data['primary_title'] = 'feedback1_layanan';
		$data['sub_primary_title'] = 'Edit feedback1_layanan';

		//ambil data dari model dengan berdasarkan parameter diatas
		$data['list'] = $this->m_feedback1_layanan->get_by($params);
		$data['diagnosa'] = $this->m_feedback1_layanan->get_diagnosa();
		$data['kat_penunjang'] = $this->m_feedback1_layanan->get_penunjang();

		//menggunakan theme back
		$this->layout->theme('back','feedback1_layanan/edit', $data);
	}

	function update() {
		//rule type pada function ini: Create
		$this->rule->type('U');
		$user = $this->ion_auth->user()->row();
		$kd_feedback1_layanan=$this->input->post('kd_feedback1_layanan');
			$dataUpdate = array(
				'tgl_feedback1_layanan' => $this->input->post('tglfeedback1_layanan'),
				'tgl_masuk' => $this->input->post('tglmasuk'),
				'tgl_keluar' => $this->input->post('tglkeluar'),
				'no_rm' => $this->input->post('norm'),
				'ket_feedback1' => $this->input->post('keterangan')
			);

			//simpan melalui model
			//$this->m_feedback1_layanan->save($dataInsert);

			if(!$this->m_feedback1_layanan->save($kd_feedback1_layanan,$dataUpdate)){
				$this->session->set_flashdata('gagal', 'Kode feedback1_layanan <b>'.$this->input->post('kd_feedback1_layanan').'</b> dari peserta <b>'.$this->input->post('nama').'</b> gagal dirubah.');
				redirect('feedback1_layanan','refresh');
			}else{
				$this->session->set_flashdata('sukses', 'Kode feedback1_layanan <b>'.$this->input->post('kd_feedback1_layanan').'</b> dari peserta <b>'.$this->input->post('nama').'</b> berhasil dirubah.');
				redirect('feedback1_layanan','refresh');
			}

			redirect('feedback1_layanan');
		
	}

	function delete($id_agama = '') {

		//rule type pada function ini: Delete
		$this->rule->type('D');

		if(!$this->m_feedback1_layanan->delete($id_agama)){
			$this->session->set_flashdata('gagal', 'Data gagal dihapus.');
			redirect($_SERVER['HTTP_REFERER'],'refresh');
		}else{
			$this->session->set_flashdata('sukses', 'Data berhasil dihapus.');
			redirect($_SERVER['HTTP_REFERER'],'refresh');
		}
	}

	

	function excel(){
		$this->rule->type('R');
		//load our new PHPExcel library
		$this->load->library('excel');
		//activate worksheet number 1
		$this->excel->setActiveSheetIndex(0);
		//name the worksheet
		$this->excel->getActiveSheet()->setTitle('Data feedback1_layanan');
		//set cell A1 content with some text
		$this->excel->getActiveSheet()->setCellValue('A1', 'Data feedback1_layanan Raksa Abadi Informatika');
		$this->excel->getActiveSheet()->setCellValue('A2', 'No.');
		$this->excel->getActiveSheet()->setCellValue('B2', 'feedback1_layanan');
		//change the font size
		$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(11);
		//make the font become bold
		$this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
		//merge cell A1 until D1
		$this->excel->getActiveSheet()->mergeCells('A1:D1');
		//set aligment to center for that merged cell (A1 to D1)
		$this->excel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
		//set style
	  $TitleStyle = array(
	    'borders' => array(
        'allborders' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN
        )
	    ),
	    'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => '00994C') // hijau tua
      ),
      'font'  => array(
	      'bold'  => false,
	      'color' => array('rgb' => 'FFFFFF'),
	      'size'  => 15,
	      'name'  => 'Verdana'
  		)
  	);

	  $HeaderStyle = array(
	    'borders' => array(
        'allborders' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN
        )
	    ),
	    'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => '32CD32') // hijau
      )
  	);

  	$ContentStyle = array(
	    'borders' => array(
        'allborders' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN
        )
	    ),
	    'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => 'FFFF00') // kuning
      )
  	);
  	
		$this->excel->getActiveSheet()->getStyle('A1:D1')->applyFromArray($TitleStyle);
		$this->excel->getActiveSheet()->getStyle('A2:B2')->applyFromArray($HeaderStyle);
		//isi
		$list_data = $this->m_feedback1_layanan->get_export();
		$cols = 3;
		$num = 1;
		foreach($list_data as $row){
			$col = $cols++;
			$this->excel->getActiveSheet()->setCellValue('A' . $col, $num++);
			$this->excel->getActiveSheet()->setCellValue('B' . $col, $row['agama']);
		}

		//warna
		$cols2 = 3;
		foreach($list_data as $row){
			$col2 = $cols2++;
			$this->excel->getActiveSheet()->getStyle('A' . $col2)->applyFromArray($ContentStyle);
			$this->excel->getActiveSheet()->getStyle('B' . $col2)->applyFromArray($ContentStyle);
		}

		$this->excel->getActiveSheet()->getColumnDimension("A")->setAutoSize(true);
		$this->excel->getActiveSheet()->getColumnDimension("B")->setAutoSize(true);


		$filename='Master Data feedback1_layanan.xls'; //save our workbook as this file name
		header('Content-Type: application/vnd.ms-excel'); //mime type
		header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
		header('Cache-Control: max-age=0'); //no cache
		            
		//save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
		//if you want to save it as .XLSX Excel 2007 format
		$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');  
		//force user to download the Excel file without writing it to server's HD
		$objWriter->save('php://output');
	}

	function pdf(){
		// rule type
		$this->rule->type('R');
		//ambil data
		$data['results'] = $this->m_feedback1_layanan->get_export();
		// pdf library
		$this->load->library('pdf');
		ob_start();		
		$this->load->view('back/layouts/feedback1_layanan/pdf', $data);
    $content = ob_get_clean();
  	try{
  		// L => Landscape, P => Potrait, array(215,330) => ukuran kertas, array(10, 10, 5, 5) => margin
      $html2pdf = new HTML2PDF('P', array(215,330), 'en', true, 'UTF-8', array(10, 10, 5, 5));
      $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
      $html2pdf->Output("data_agama.pdf");
  	}
  	catch(HTML2PDF_exception $e) {
      echo $e;
      exit;
  	}
	}

	function get_feedback1_layanan() {
		$kd_peserta  	= $this->input->post('kd_peserta');
		//echo $kd_peserta;
		$data 				= $this->m_feedback1_layanan->get_peserta($kd_peserta);
		$jumlah 			= count($data);
		if($jumlah > 0){
			$arr_data = array(
				'stts'		=> "ada",
				'nama'		=> $data['nama'],
				'nopeserta'	=> $data['peserta'],
				'alamat'	=> $data['alamat'],
				'kd_ppk'	=> $data['kd_ppk'],
				'ttl'	=> $data['tempat_lahir'].", ".tgl_saja($data['tgl_lahir']),
				);
		}else{
			$arr_data = array(
				'stts'		=> "tdk",
				'nama'		=> "Tidak ditemukan, masukan Kd. Peserta yang benar",
				'nopeserta'	=> "Tidak ditemukan, masukan Kd. Peserta yang benar",
				'alamat'	=> "Tidak ditemukan, masukan Kd. Peserta yang benar",
				'kd_ppk'	=> "Tidak ditemukan, masukan Kd. Peserta yang benar",
				'ttl'	=> "Tidak ditemukan, masukan Kd. Peserta yang benar",
			);
		}
		echo json_encode($arr_data);
	}

	function get_layanan() {
		//$keyword 	= $this->input->post('kd_peserta');
		$keyword 	= $this->uri->segment(3);
		//$keyword 	= $_GET('kd_peserta');
		$data['layanan'] 	= $this->m_feedback1_layanan->get_layanan($keyword);
		$data['jumlah'] 	= count($data);
		$this->load->view('back/layouts/feedback1_layanan/ajax/layanan',$data);
		
	}
	function get_layanan_by() {
		$keyword 	= $this->input->post('layanan');
		//$keyword 	= $this->uri->segment(3);
		//$keyword 	= $_GET('kd_peserta');
		//echo $keyword;
		$params=array($keyword);
		$data 				= $this->m_feedback1_layanan->get_layanan_by($keyword);
		$jumlah 			= count($data);
		if ($jumlah>0) {
			$arr_data= array(
				'kd_layanan'=> $data['kd_layanan'],
				'layanan'	=> $data['layanan'],
				'tarif'	=> $data['tarif'],
				'jumlah'	=> 1,
				);
		}else{
			$arr_data= array(
				'kd_layanan'=> "",
				'layanan'	=> "",
				'tarif'	=> "",
				);

		}

		echo json_encode($arr_data);
	}

	function get_layanan_feedback1_layanan() {
		//$keyword 	= $this->input->post('kd_feedback1_layanan');
		$keyword 	= $this->uri->segment(3);
		//$keyword 	= $_GET('kd_peserta');
		//echo $keyword;
		$data['layanan_feedback1_layanan'] 	= $this->m_feedback1_layanan->get_layanan_feedback1_layanan($keyword);
		$data['jumlah'] 		= count($data['layanan_feedback1_layanan']);
		$this->load->view('back/layouts/feedback1_layanan/ajax/layanan_feedback1_layanan',$data);
		
	}

	function simpan_layanan()
	{
		
		$perda=$this->input->post('tarif_perda');
		$diminta=$this->input->post('tarif_diminta');
		if ($perda>$diminta) {
			$feedback=$diminta;
		}elseif ($diminta>$perda) {
			$feedback=$perda;
		}elseif($perda=$diminta){
			$feedback=$perda;
		}
		$data = array(
            'kd_layanan' => $this->input->post('kd_layanan'),
            'kd_feedback1_layanan' => $this->input->post('kd_feedback1_layanan'),
            'tarif_perda' => $this->input->post('tarif_perda'),
            'tarif_diminta' => $this->input->post('tarif_diminta'),
            'frekuensi_diminta' => $this->input->post('jumlah'),
            'tarif_feedback1' => $feedback,
            'tgl_input' => date("Y-m-d"),
                //'brgShow' => 1,   
        );

        $this->m_feedback1_layanan->save_layanan($data);


	}

	

	function edit_layanan() {
		$keyword 	= $this->input->post('layanan');
		//$keyword 	= $this->uri->segment(3);
		//$keyword 	= $_GET('kd_peserta');
		//echo $keyword;
		//echo '<select>';
		$data['layanan_feedback1_layanan'] 	= $this->m_feedback1_layanan->get_layanan_feedback1_layanan_by($keyword);
		$data['jumlah'] 		= count($data['layanan_feedback1_layanan']);
		$this->load->view('back/layouts/feedback1_layanan/ajax/layanan_edit',$data);
		
	}

	function update_layanan()
	{
		
		$perda=$this->input->post('tarif_perda');
		$diminta=$this->input->post('tarif_diminta');
		$id=$this->input->post('id');
		if ($perda>$diminta) {
			$feedback=$diminta;
		}elseif ($diminta>$perda) {
			$feedback=$perda;
		}elseif($perda=$diminta){
			$feedback=$perda;
		}
		$dataUpdate = array(
            'tarif_perda' => $this->input->post('tarif_perda'),
            'tarif_diminta' => $this->input->post('tarif_diminta'),
            'frekuensi_diminta' => $this->input->post('jumlah'),
            'tarif_feedback1' => $feedback,
                //'brgShow' => 1,   
        );

        $this->m_feedback1_layanan->update_layanan($id,$dataUpdate);


	}

	function delete_layanan(){
		$id=$this->input->post('layanan');
		$keyword=$this->input->post('feedback1_layanan');
			
		if($this->m_feedback1_layanan->delete_layanan($id)){
			$data['layanan_feedback1_layanan'] 	= $this->m_feedback1_layanan->get_layanan_feedback1_layanan($keyword);
			$data['jumlah'] 		= count($data['layanan_feedback1_layanan']);
			$this->load->view('back/layouts/feedback1_layanan/ajax/layanan_feedback1_layanan',$data);
			
		}else{
			echo "Gagal";
			
		}
	}

	//diagnosa
	//get feedback1_layanan diagnosa
	function get_diagnosa_feedback1_layanan(){
		//$keyword 	= $this->input->post('kd_feedback1_layanan');
		$keyword 	= $this->uri->segment(3);
		//$keyword 	= $_GET('kd_peserta');
		//echo $keyword;
		$data['diagnosa_feedback1_layanan'] = $this->m_feedback1_layanan->get_diagnosa_feedback1_layanan($keyword);
		$data['jumlah'] 		= count($data['diagnosa_feedback1_layanan']);
		$this->load->view('back/layouts/feedback1_layanan/ajax/diagnosa_feedback1_layanan',$data);
	}

	//save diagnosa
	function simpan_diagnosa()
	{
		
		
		$data = array(
            'kd_diagnosa' => $this->input->post('kd_diagnosa'),
            'kd_feedback1_layanan' => $this->input->post('kd_feedback1_layanan'),
        );

        $this->m_feedback1_layanan->save_diagnosa($data);


	}
	//delete diagnosa
	function delete_diagnosa(){
		$id=$this->input->post('diagnosa');
		$keyword=$this->input->post('feedback1_layanan');
			
		if($this->m_feedback1_layanan->delete_diagnosa($id)){
			$data['diagnosa_feedback1_layanan'] 	= $this->m_feedback1_layanan->get_diagnosa_feedback1_layanan($keyword);
			$data['jumlah'] 		= count($data['diagnosa_feedback1_layanan']);
			$this->load->view('back/layouts/feedback1_layanan/ajax/diagnosa_feedback1_layanan',$data);
			
		}else{
			echo "Gagal";
			
		}
	}

	//penunjang
	//get penunjang feedback1_layanan
	function get_penunjang_feedback1_layanan(){
		//$keyword 	= $this->input->post('kd_feedback1_layanan');
		$keyword 	= array($this->uri->segment(3),$this->uri->segment(4));
		//$keyword 	= $_GET('kd_peserta');
		//echo $keyword;
		$data['penunjang_feedback1_layanan'] = $this->m_feedback1_layanan->get_penunjang_feedback1_layanan($keyword);
		$data['jumlah'] 		= count($data['penunjang_feedback1_layanan']);
		$this->load->view('back/layouts/feedback1_layanan/ajax/penunjang_feedback1_layanan',$data);
	}

	//get penunjang
	function get_penunjang_pilihan() {
		//$keyword 	= $this->input->post('kd_peserta');
		$keyword 	= array($this->uri->segment(3),$this->uri->segment(4));
		$keyword2 	= $this->uri->segment(4);
		//$keyword 	= $_GET('kd_peserta');
		$data['penunjang'] 	= $this->m_feedback1_layanan->get_penunjang_pilihan($keyword);
		$data['kat_penunjang_by'] = $this->m_feedback1_layanan->get_mpenunjang_by($keyword2);
		$data['jumlah'] 	= count($data['penunjang']);
		$this->load->view('back/layouts/feedback1_layanan/ajax/penunjang',$data);
		
	}

	//get penunjang by
	function get_penunjang_by() {
		$keyword 	= $this->input->post('penunjang');
		//$keyword 	= $this->uri->segment(3);
		//$keyword 	= $_GET('kd_peserta');
		//echo $keyword;
		$params=array($keyword);
		$data 				= $this->m_feedback1_layanan->get_penunjang_by($keyword);
		$jumlah 			= count($data);
		if ($jumlah>0) {
			$arr_data= array(
				'kd_penunjang'=> $data['kd_penunjang'],
				'penunjang'	=> $data['penunjang'],
				'tarif'	=> $data['tarif'],
				'jumlah'	=> 1,
				);
		}else{
			$arr_data= array(
				'kd_penunjang'=> "",
				'penunjang'	=> "",
				'tarif'	=> "",
				);

		}

		echo json_encode($arr_data);
	}

	//save penunjang
	function simpan_penunjang()
	{
		
		$perda=$this->input->post('tarif_perda');
		$diminta=$this->input->post('tarif_diminta');
		if ($perda>$diminta) {
			$feedback=$diminta;
		}elseif ($diminta>$perda) {
			$feedback=$perda;
		}elseif($perda=$diminta){
			$feedback=$perda;
		}
		$data = array(
            'kd_penunjang' => $this->input->post('kd_penunjang'),
            'kd_feedback1_layanan' => $this->input->post('kd_feedback1_layanan'),
            'tarif_perda' => $this->input->post('tarif_perda'),
            'tarif_diminta' => $this->input->post('tarif_diminta'),
            'frekuensi_diminta' => $this->input->post('jumlah'),
            'tarif_feedback1' => $feedback,
            'tgl_input' => date("Y-m-d"),
                //'brgShow' => 1,   
        );

        $this->m_feedback1_layanan->save_penunjang($data);


	}
	//hapus penunjang
	function delete_penunjang(){
		$id=$this->input->post('penunjang');
		$keyword=array($this->input->post('feedback1_layanan'),$this->input->post('kategori'));
			
		if($this->m_feedback1_layanan->delete_penunjang($id)){
			$data['penunjang_feedback1_layanan'] 	= $this->m_feedback1_layanan->get_penunjang_feedback1_layanan($keyword);
			$data['jumlah'] 		= count($data['penunjang_feedback1_layanan']);
			$this->load->view('back/layouts/feedback1_layanan/ajax/penunjang_feedback1_layanan',$data);
			
		}else{
			echo "Gagal";
			
		}
	}

	//edit penunjang
	function edit_penunjang() {
		$keyword 	= $this->input->post('penunjang');
		//$keyword 	= $this->uri->segment(3);
		//$keyword 	= $_GET('kd_peserta');
		//echo $keyword;
		//echo '<select>';
		$data['penunjang_feedback1_layanan'] 	= $this->m_feedback1_layanan->get_penunjang_feedback1_layanan_by($keyword);
		$data['jumlah'] 		= count($data['penunjang_feedback1_layanan']);
		$this->load->view('back/layouts/feedback1_layanan/ajax/penunjang_edit',$data);
		
	}

	function update_penunjang()
	{
		
		$perda=$this->input->post('tarif_perda');
		$diminta=$this->input->post('tarif_diminta');
		$id=$this->input->post('id');
		if ($perda>$diminta) {
			$feedback=$diminta;
		}elseif ($diminta>$perda) {
			$feedback=$perda;
		}elseif($perda=$diminta){
			$feedback=$perda;
		}
		$dataUpdate = array(
            'tarif_perda' => $this->input->post('tarif_perda'),
            'tarif_diminta' => $this->input->post('tarif_diminta'),
            'frekuensi_diminta' => $this->input->post('jumlah'),
            'tarif_feedback1' => $feedback,
                //'brgShow' => 1,   
        );

        $this->m_feedback1_layanan->update_penunjang($id,$dataUpdate);


	}
}
